package com.zhangdy.agent;

import com.sun.tools.attach.VirtualMachine;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.lang.management.ManagementFactory;

@SpringBootApplication(scanBasePackages = {"com.zhangdy"}, exclude = {DataSourceAutoConfiguration.class})
@EnableAspectJAutoProxy(exposeProxy=true,proxyTargetClass=true)
@MapperScan(basePackages = {"com.zhangdy.agent.mapper"})
@EnableTransactionManagement
public class ZhangdyAgentApplication {

	public static void main(String[] args)  throws Exception{
		SpringApplication.run(ZhangdyAgentApplication.class, args);

//
//		String name = ManagementFactory.getRuntimeMXBean().getName();
//		// get pid
//		String pid = name.split("@")[0];
//		VirtualMachine virtualMachine = VirtualMachine.attach(pid);
////            virtualMachine.loadAgent("E:\\run-jar\\zhangdy-agent\\zhangdy-agent-core-0.0.1-SNAPSHOT.jar");
//            virtualMachine.loadAgent("/Users/zhangdaye/jar/zhangdy-agent-core-0.0.1-SNAPSHOT.jar");
////            virtualMachine.loadAgent("/mnt/e/run-jar/zhangdy-agent/zhangdy-agent-core-0.0.1-SNAPSHOT.jar");
////		virtualMachine.loadAgent("E:\\run-jar\\zhangdy-agent\\zhangdy-agent-core-0.0.1-SNAPSHOT.jar");
////            virtualMachine.loadAgent("/mnt/e/run-jar/zhangdy-agent/zhangdy-agent-core-0.0.1-SNAPSHOT.jar");
//		// 需要finally
//		virtualMachine.detach();

	}

}
